package com.chuangke.lowcode.util;

import com.chuangke.common.annotation.Entity;

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;

public class LowCodeUtils {

    /**
     * 获取模型实体的子模型字段
     *
     * @param clazz
     * @return
     */
    public static List<Field> getEntityFields(Class<?> clazz) {
        Field[] fields = clazz.getDeclaredFields();
        List<Field> entityFields = new ArrayList<>();
        for (Field field : fields) {
            if (field.getAnnotation(Entity.class) != null) {
                entityFields.add(field);
            }
        }
        return entityFields;
    }
}
